import QtQuick 2.6
import Sailfish.Silica 1.0
import "../component"
import "../config"

Page {
    id: mainPage
    backNavigation: false   //禁止返回上一个页面
    //设置屏幕方向
    allowedOrientations: defaultAllowedOrientations

    //页面pageView
    UITabView {
           id: tabView
           height: parent.height - bottomNavigationBar.height
           width: parent.width - 40
           anchors.horizontalCenter: parent.horizontalCenter
           interactive: false
           orientation: Qt.Horizontal
           clip: true

           property var carouselPages: ["HomePage.qml", "PersonPage.qml"]
           property int initialPage: 0
           model: carouselPages.length
           Component.onCompleted: {
               console.log("屏幕的高度是：" + parent.height)
               console.log("导航栏的高度是：" + bottomNavigationBar.height)
               console.log("自己的高度是：" + height)
               currentIndex = initialPage
           }

           delegate: Loader {
               id: pageLoader
               x: tabView.currentIndex === index ? 0 : tabView.width * (index > tabView.currentIndex? 1 : -1)
               width: tabView.itemWidth
               height: tabView.height
               source: tabView.carouselPages[index]
               asynchronous: false

               Behavior on x {
                   NumberAnimation {
                       duration: 300
                       easing.type: Easing.OutCubic
                   }
               }
           }
       }


       //底部导航栏
       UIBottomNavigation {
           id: bottomNavigationBar
           width: parent.width
           tabView: tabView
           iconArray: ["../img/icon_home.svg","../img/icon_person.svg"]
           nameArray: ["书架","设置"]
           anchors.top: tabView.bottom
       }
}
